package com.stateMode;

/**
 * 抽奖活动，持有抽奖状态对象
 */
public class RaffleActivity {
    //活动当前的状态，分为 不可抽奖 ， 扣钱，可抽奖，抽中奖品。
    private State state ;

    private int count = 0 ; //当前奖品的数量

    //四种状态都要组合到这个类中
    State noRaffleState = new NoRaffleState(this);
    State canRaffleState =new CanRaffleState(this);
    State dispenseState =new DispenseState(this);
    State dispensOutState =new DispenseOutState(this);

    //构造
    public RaffleActivity(int count) {
        //设置初始状态为不可抽奖状态
        this.state = new NoRaffleState(this);
        this.count = count;
    }

    //扣分   调用当前状态的对象，去扣分
    public void deductMoney(){
        this.state.deductMoney();
    }

    //抽奖
    public void raffle(){
        //判断当前状态是否可以抽奖
        if (this.state.raffle()){
            //如果可以抽奖就获得奖品
            state.dispensePrise();
        }
    }

    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }

    public int getCount() {
        return this.count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public State getNoRaffleState() {
        return noRaffleState;
    }

    public State getCanRaffleState() {
        return canRaffleState;
    }

    public State getDispenseState() {
        return dispenseState;
    }

    public State getDispensOutState() {
        return dispensOutState;
    }
}
